package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsJyj;
import com.ruoyi.yqhs.service.IYqhsJyjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 加油机信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-31
 */
@RestController
@RequestMapping("/yqhs/jyj")
public class YqhsJyjController extends BaseController
{
    @Autowired
    private IYqhsJyjService yqhsJyjService;

    /**
     * 查询加油机信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:jyj:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqhsJyj yqhsJyj)
    {
        startPage();
        List<YqhsJyj> list = yqhsJyjService.selectYqhsJyjList(yqhsJyj);
        return getDataTable(list);
    }

    /**
     * 导出加油机信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:jyj:export')")
    @Log(title = "加油机信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsJyj yqhsJyj)
    {
        List<YqhsJyj> list = yqhsJyjService.selectYqhsJyjList(yqhsJyj);
        ExcelUtil<YqhsJyj> util = new ExcelUtil<YqhsJyj>(YqhsJyj.class);
        util.exportExcel(response, list, "加油机信息数据");
    }

    /**
     * 获取加油机信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jyj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqhsJyjService.selectYqhsJyjById(id));
    }

    /**
     * 新增加油机信息
     */
    @PreAuthorize("@ss.hasPermi('system:jyj:add')")
    @Log(title = "加油机信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsJyj yqhsJyj)
    {
        return toAjax(yqhsJyjService.insertYqhsJyj(yqhsJyj));
    }

    /**
     * 修改加油机信息
     */
    @PreAuthorize("@ss.hasPermi('system:jyj:edit')")
    @Log(title = "加油机信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsJyj yqhsJyj)
    {
        return toAjax(yqhsJyjService.updateYqhsJyj(yqhsJyj));
    }

    /**
     * 删除加油机信息
     */
    @PreAuthorize("@ss.hasPermi('system:jyj:remove')")
    @Log(title = "加油机信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqhsJyjService.deleteYqhsJyjByIds(ids));
    }
}
